unless defined? RADIANT_ROOT
  ENV["RAILS_ENV"] = "test"
  require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/boot"
  require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
end

require 'spec/rails'

Spec::Runner.configure do |config|
  config.use_transactional_fixtures = true
  config.use_instantiated_fixtures  = false
#  config.fixture_path = File.join(File.dirname(__FILE__), 'spec', 'fixtures')
  config.before(:each, :behaviour_type => :controller) do
    raise_controller_errors
  end
end

module SpecPageMixin
  class TagInspector
    attr_accessor :tag, :output
  end
  
  attr_reader :inspector
  
  include Radiant::Taggable
  
  def inspect_render(text)    
    @inspector = TagInspector.new
    @inspector.output = parse(text)
    @inspector
  end
  
  desc %{Sets an @inspector instance variable of the current page so that the context inside a tag can be captured}
  tag "inspect" do |tag|
    @inspector.tag = tag
  end
end

Page.send(:include, SpecPageMixin)
